package com.zxq.common.utils;


import com.zxq.common.utils.internal.id.Snowflake;

/**
 * 全局ID生成
 */
public class IdUtil {

    private static final Snowflake snowflake;

    static {
        int workerId = (int) (Math.random() * 1000) % 32;
        int dataCenterId = (int) (Math.random() * 1000) % 32;
        snowflake = new Snowflake(workerId % 32, dataCenterId % 32, true);
    }

    /**
     * @return 获取下一个id
     */
    public static long nextId() {
        return snowflake.nextId();
    }

}
